package com.gxa.service.impl;

import com.gxa.domain.dto.CarManageDTO;
import com.gxa.domain.entity.CarManage;
import com.gxa.mapper.CarManageMapper;
import com.gxa.service.CarManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * User: gxb
 * Date: 2024/07/16  11:47
 * Description:
 * Version: V1.0
 */
@Service//IOC注解  把当前service创建一个对象 交给spring进行管理
@Transactional//开启事务 事务是指逻辑上的一组要操作，要么都成功，要么都是失败
public class CarManageServiceImpl implements CarManageService {
    //di依赖注入  会从spring容器中获取drugMapper对象，然后进行设置
    @Autowired
    private CarManageMapper carManageMapper;

    @Override
    public void insertCarManage(CarManage carManage) {
        carManageMapper.insertCarManage(carManage);

    }

    @Override
    public CarManage findCarManageById(Long id) {
        if(id==null){
            return null;
        }
        return carManageMapper.findCarManageById(id);
    }

    @Override
    public List<CarManage> findCarManageAll() {
        return carManageMapper.findCarManageAll();
    }

    @Override
    public void updateCarManage(CarManage carManage) {
        carManageMapper.updateCarManage(carManage);
    }

    @Override
    public void deleteCarManageById(Long id) {
        if(id==null){
            return;
        }
        carManageMapper.deleteCarManageById(id);
    }

    @Override
    public List<CarManage> findCarManageByWhere(CarManageDTO carManageDTO) {
        return carManageMapper.findCarManageByWhere(carManageDTO);
    }
}
